package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28779
 * Date: 2023-08-20
 * Time: 15:46
 */
//线程状态
public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

        System.out.println(t.getState());  //NEW 安排了，还未开始执行

        t.start();

        System.out.println(t.getState());  //RUNNABLE  正在运行

        Thread.sleep(1000);
        System.out.println(t.getState());  //TIMED_WAITING 正处于sleep阻塞状态

        t.join();

        System.out.println(t.getState());  //TERMINATED 线程结束
    }
}
